import 'dart:ffi';

import 'package:flutter_code_framework/model_data/classinfo/classinfo.dart';
import 'package:json_annotation/json_annotation.dart';

part 'homeworkclass.g.dart';

@JsonSerializable()
class HomeworkClass {
  String id;
  String name;
  int openNumb;
  int submitNumb;
  String submitRate;
  List<StudentList> studentList;

  HomeworkClass(
      {this.id,
      this.name,
      this.studentList,
      this.openNumb,
      this.submitNumb,
      this.submitRate});
//反序列化
  HomeworkClass.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    openNumb = json['openNumb'];
    submitNumb = json['submitNumb'];
    submitRate = json['submitRate'];
    if (json['studentList'] != null) {
      studentList = new List<StudentList>();
      json['studentList'].forEach((v) {
        studentList.add(new StudentList.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['openNumb'] = this.openNumb;
    data['submitNumb'] = this.submitNumb;
    data['submitRate'] = this.submitRate;
    if (this.studentList != null) {
      data['studentList'] = this.studentList.map((v) => v.toJson()).toList();
    }
    return data;
  }
}
